<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@page import="javax.jdo.PersistenceManager"%>
<%@page import="java.util.List"%>
<%@page import="com.google.appengine.api.datastore.Text"%>
<%@page import="java.util.Date"%>
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>RSS news</title>
	</head>
	<body>				
		<%					
					final ReadController controller = new ReadController(request);
					controller.setSession(session);
					controller.doJob();		
					final ReadModel model = controller.getModel();					
		%>
		<table>
			<tr>			
				<%					
					if(controller.renderBack())
					{
				%>
				<td>
					<form action="/r.jsp" method="post">
						<input type="hidden" name="<%=Constants.COMMAND%>" value="<%=Constants.BACK_COMMAND%>" /> 
						<input type="hidden" name="<%=Constants.VALUE_HISTORY_INDEX%>" value="<%=controller.getHistoryIndex()%>" /> 					
						<input type="submit" value="Back" />
					</form>
				</td>
				<%
					}
					if(controller.renderForward())
					{
				%>		
				<td>		
					<form action="/r.jsp" method="post">
						<input type="hidden" name="<%=Constants.COMMAND%>" value="<%=Constants.FORWARD_COMMAND%>" />
						<input type="hidden" name="<%=Constants.VALUE_HISTORY_INDEX%>" value="<%=controller.getHistoryIndex()%>" /> 					
					<input type="submit" value="Forward" />
					</form>
				</td>
				<%
					}
					if(model!=null && model.getId()!=null)
					{
				%>
				<td>
					<form action="/r.jsp" method="post">
						<input type="hidden" name="<%=Constants.COMMAND%>" value="<%=Constants.MARK_AS_READED_COMMAND%>" /> 
						<input type="hidden" name="<%=Constants.VALUE_ID%>" value="<%=model.getId()%>" /> 
						<input type="submit" value="Mark as read" />
					</form>
				</td>
		
			</tr>
		</table>
		<h1><%=model.getTitle()%></h1>
		<h3><%=model.getAuthor()%></h3>
		<h3><%=model.getModified()%></h3>
		<p><%=model.getSummury()%></p>
		<%
			if (model.getLink() != null) {
		%>
		<p><a href="<%=model.getLink()%>"><%=model.getLink()%></a></p>
		<%
			}
		%>
		<table>
			<tr>
		
				<td>
					<form action="/r.jsp" method="post">
						<input type="hidden" name="<%=Constants.COMMAND%>" value="<%=Constants.MARK_AS_READED_COMMAND%>" /> 
						<input type="hidden" name="<%=Constants.VALUE_ID%>" value="<%=model.getId()%>" /> 
						<input type="submit" value="Mark as read" />
					</form>
				<form action="/r.jsp" method="post">
					<input type="hidden" name="<%=Constants.COMMAND%>" value="<%=Constants.SEND_TO_COMMAND%>" />
					<input type="hidden" name="<%=Constants.VALUE_ID%>" value="<%=model.getId()%>" /> 
					<input type="submit" value="Post" />
				</form>
				</td>
		
			</tr>
		</table>
		<%} %>
	</body>
</html>
<%@page import="com.appengine.news.Constants"%>
<%@page import="com.appengine.news.utils.PMF"%>
<%@page import="com.appengine.news.entity.RssItemEntity"%>
<%@page import="com.appengine.news.utils.HTMLSanitiser"%>
<%@page import="com.appengine.news.ui.controller.ReadController"%>
<%@page import="com.appengine.news.ui.model.ReadModel"%>